Skip to content

Add custom item offset scrolling#615

Open
aaalaniz wants to merge 2 commits into
square:mainfrom
aaalaniz:aalaniz/listable-item-offset-scrolling
Open

Add custom item offset scrolling#615
aaalaniz wants to merge 2 commits into
square:mainfrom
aaalaniz:aalaniz/listable-item-offset-scrolling

Conversation

@aaalaniz
Copy link
Copy Markdown

@aaalaniz aaalaniz commented May 21, 2026

Adds a Listable-owned API for custom vertical item positioning from both imperative ListActions and declarative AutoScrollAction.

What's changed

  • Adds ListItemScrollPosition.standard(_:) and .verticalContentOffsetAdjustment(_:).
  • Adds AutoScrollAction.scrollTo(... itemPosition:) and pin(... itemPosition:), with existing position: overloads preserved.
  • Adds AutoScrollAction.ScrollInterruptionPolicy:
    • .performImmediately
    • .deferDuringUserScrolling
    • .skipDuringUserScrolling
  • Keeps custom adjustments vertical-only; no horizontal offset API is added.
  • Adds a generic demo: Custom Auto Scrolling (Footer-Aware Pin).
  • Adds tests for custom declarative auto-scroll, callback behavior, deferral, and skip policy.

Example

list.autoScrollAction = .pin(
    .item(targetIdentifier),
    itemPosition: .verticalContentOffsetAdjustment { info in
        max(0.0, info.itemFrame.maxY - info.visibleContentFrame.maxY)
    },
    scrollInterruptionPolicy: .deferDuringUserScrolling
)

Use .skipDuringUserScrolling when an auto-scroll request should be dropped instead of retried after user scrolling ends.

Visuals

auto-scroll-vertical-offset-rotated.mov

Test Plan

  • mise exec -- xcodebuild test -workspace Development/ListableDevelopment.xcworkspace -scheme ListableDevelopment-Workspace -destination 'id=52DC49DC-0376-4B43-99BE-BC7A016A51B3' -derivedDataPath /tmp/listable-dd-development-tests -only-testing:ListableTests
  • git diff --check
  • Built and launched Custom Auto Scrolling (Footer-Aware Pin) demo on iOS Simulator

Checklist

Please do the following before merging:

  • Ensure any public-facing changes are reflected in the changelog. Include them in the Main section.

Expose a Listable-owned item scrolling API that lets callers compute
a vertical content offset adjustment without accessing the scroll view.
@aaalaniz
Copy link
Copy Markdown
Author

🤖 @codex review

list.animation = .fast
list.scrollIndicatorInsets.bottom = 112.0

list.autoScrollAction = .pin(
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new API in action

@discardableResult
public func scrollTo(
item : AnyIdentifier,
contentOffsetAdjustment : @escaping ListItemScrollPositionAdjustment,
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's okay that this is marked as escaping but making a note for myself

}
}

self.testcase("skips while dragging") {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add coverage when user specifies to skip scroll during scroll

@aaalaniz aaalaniz marked this pull request as ready for review May 22, 2026 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant